﻿using Microsoft.Phone.Controls;
using System;
using WaitLess.App.Services.Interfaces;

namespace WaitLess.App.Services
{
    public class NavigationService : INavigationService
    {
        private static readonly Uri MainPage = new Uri("/Views/MainPage.xaml", UriKind.Relative);
        private static readonly Uri DetailsPage = new Uri("/Views/DetailsPage.xaml", UriKind.Relative);
        private static readonly Uri FoursquarePage = new Uri("/Views/FoursquarePage.xaml", UriKind.Relative);

        public PhoneApplicationFrame RootFrame
        {
            get
            {
                return ((App)App.Current).RootFrame;
            }
        }

        public bool Navigate(Uri source)
        {
            return RootFrame.Navigate(source);
        }

        public bool NavigateToMainPage()
        {
            return Navigate(MainPage);
        }

        public bool NavigateToDetailsPage(string municipalOfficeId)
        {
            return Navigate(GetDetailsPageUri(municipalOfficeId));
        }

        public Uri GetDetailsPageUri(string municipalOfficeId)
        {
            return new Uri(string.Format("{0}?municipalOfficeId={1}", DetailsPage, municipalOfficeId), UriKind.Relative);
        }

        public Uri GetFoursquarePageUri(Uri redirectUri)
        {
            return new Uri(string.Format("{0}?redirect={1}", FoursquarePage, redirectUri), UriKind.Relative);
        }
    }
}